{layout name="layout" /}
<div id="actionbar" class="fn-clear">
    <div class="fn-left">
        <a href="{:url('entrust/index')}" class="button {if !$types} button-green{/if}">全部商品</a>
        <a href="{:url('entrust/index',['types'=>1,'keyword' => $keyword])}" class="button {if $types ==1} button-green{/if}">未成交</a>
        <a href="{:url('entrust/index',['types'=>2,'keyword' => $keyword])}" class="button {if $types ==2} button-green{/if}">已成交</a>
        <a href="{:url('entrust/index',['types'=>3,'keyword' => $keyword])}" class="button {if $types ==3} button-green{/if}">平台回购</a>
    </div>
    <div class="fn-right">
        <form id="form" action="{:url('entrust/index')}" method="get">
            <input type="hidden" name="types" value="{$types}" />
            <input placeholder="请输入用户完整手机号" class="input w200" type="text" name="keyword" value="{$keyword}" />
            <input type="submit" value="搜索" class="button button-blue" />
        </form>
    </div>
</div>
<div class="cards">
    <div class="card blue">
        <div class="fn-left"><i class="iconfont icon-my_icon"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$on_under}</div><div class="text">已上架</div></div>
    </div>
    <div class="card blue">
        <div class="fn-left"><i class="iconfont icon-my_icon"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$off_under}</div><div class="text">未上架</div></div>
    </div> 
    <div class="card green">
        <div class="fn-left"><i class="iconfont icon-my_icon"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$on_rebate}</div><div class="text">未成交</div></div>
    </div>
    <div class="card green">
        <div class="fn-left"><i class="iconfont icon-my_icon"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$off_rebate}</div><div class="text">已成交</div></div>
    </div>
    <div class="card red">
        <div class="fn-left"><i class="iconfont icon-my_icon"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$diy}</div><div class="text">已回购</div></div>
    </div>

</div>
<table class="table">
    <thead>
        <tr>
            <th class="w80 fn-tac">#</th>
            <th class="w80 fn-tac">用户</th>
            <th class="w80"></th>
            <th>订单详情</th>
            <th class="w140 fn-tac">委托时间</th>
            <th class="w100 fn-tac">订单价</th>
            <th class="w100 fn-tac">状态</th>
            <th class="w100 fn-tac">委托时间</th>
            <th class="w100 fn-tac">上下架</th>
            <th class="w140 fn-tac">成交时间</th>
            <th class="w100 fn-tac">成交价</th>
        </tr>
    </thead>
    <tbody>
        {foreach $lists as $key => $rs}
        <tr>
            <td class="fn-tac">{$rs.id}</td> 
            <td class="fn-tac"><img src="{$rs.face}" class="w40"/> <p>{$rs.nickname}</p></td>
            <td class="fn-tac"><img src="{$rs.img}?x-oss-process=style/80" class="w60"/></td>
            <td><a href="{:url('item/edit',['id'=>$rs.item_id])}">【{$rs.item_id}】{$rs.name}</a></td>
            <td class="fn-tac">{$rs.create_time|date='Y-m-d H:i'}</td>
            <td class="fn-tac">￥{$rs.entrust_price}</td>
            <td class="fn-tac">{if $rs.is_rebate}<span class="badge">已成交</span>{else}<span class="badge bg-red">未成交</span>{/if}</td>
            <td class="fn-tac">{$rs.howday}</td> 
            <td class="fn-tac">
                {if $rs.is_rebate}
                    <a class="button button-disabled" href="javascript:;" title="上下架">下架</a>
                {else}
                    <a class="button is_under {$rs.is_under ? 'button-green' : 'button-red'}" url="{:url('entrust/isUnder',['id' => $rs.id])}" href="javascript:;" title="上下架">{$rs.is_under ? '上架' : '下架'}</a>
                {/if}
            </td>
            <td class="fn-tac">{if $rs.update_time}{$rs.update_time|date='Y-m-d H:i'}{else}待成交{/if}</td>
            <td class="fn-tac">
                {if $rs.is_rebate}￥{$rs.rebate}{/if}
            </td>
        </tr>
        {/foreach}
    </tbody>
</table>
<div class="page fn-clear">{$pages|raw}</div>
<style type="text/css">
    .order div {margin: 5px;}
    .order .img {width: 60px;height: 60px;overflow: hidden;padding: 2px;box-sizing:border-box}
    .order .img img {width:60px;}
    .order .info {line-height: 25px;margin-top: 10px;display: block;}
    .order .info .gray {color: #9e9e9e}
    .order .number {line-height: 50px;margin: 10px 20px;}
</style>
<script type="text/javascript">
Do('base', 'layer', function () {
    $('.is_under').click(function () {
        var url = $(this).attr("url");
        parent.layer.confirm('确认要设置当前商品?',{ icon: 3,title: '友情提示' }, function (index) {
            $.getJSON(url, function (data) {window.location.reload();});
            parent.layer.close(index);
        });
    })
})
</script>